﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <script src="../App_Lib/Script/jquery-1.3.min.js" type="text/javascript"></script>

    <script type="text/javascript">


        $(document).ready(function() {

            $("#btnConvert").click(function() {

                var strData1 = $.trim($("#txtData1").val()).replace("var allUnivList =", "");
                var allU = eval(strData1);
                var cnU = allU[0];
                var uList = [];
                var cityList = [];


                $(cnU.provs).each(function(i, item) {
                    cityList.push({ id: item.id, name: item.name });
                    $(item.univs).each(function(j, jItem) {
                        jItem.c = item.id;
                        jItem.py = getPYCode(jItem.name);
                        uList.push(jItem);
                    });
                });


                var txt = "var select_provsData=[";
                $(cityList).each(function(i, item) {
                    txt += "{id:" + item.id + ",name:\"" + item.name + "\"},";
                });
                txt = txt.substr(0, txt.length - 1);
                txt += "];\r\n";
                txt += "var select_univlistData=[";
                $(uList).each(function(i, item) {
                    txt += "{id:" + item.id + ",name:\"" + item.name + "\",py:\"" + item.py + "\",c:"+item.c+"},";
                });
                txt = txt.substr(0, txt.length - 1);
                txt += "];";



                $("#txtData2").val(txt);








            });


        });
        function getPYCode(str) {
            var result = "";
            for (var i = 0; i < str.length; i++) {
                result += getPY(str.charAt(i).toString());
            }
            return result;
        }
        function getPY(s) {
            if (s != "") {
                execScript("tmp=asc(\"" + s + "\")", "vbscript");
                tmp = 65536 + tmp;
                var py = "";
                if (tmp >= 45217 && tmp <= 45252) {
                    py = "a"
                } else if (tmp >= 45253 && tmp <= 45760) {
                    py = "b"
                } else if (tmp >= 45761 && tmp <= 46317) {
                    py = "c"
                } else if (tmp >= 46318 && tmp <= 46825) {
                    py = "d"
                } else if (tmp >= 46826 && tmp <= 47009) {
                    py = "e"
                } else if (tmp >= 47010 && tmp <= 47296) {
                    py = "f"
                } else if ((tmp >= 47297 && tmp <= 47613) || (tmp == 63193)) {
                    py = "g"
                } else if (tmp >= 47614 && tmp <= 48118) {
                    py = "h"
                } else if (tmp >= 48119 && tmp <= 49061) {
                    py = "j"
                } else if (tmp >= 49062 && tmp <= 49323) {
                    py = "k"
                } else if (tmp >= 49324 && tmp <= 49895) {
                    py = "l"
                } else if (tmp >= 49896 && tmp <= 50370) {
                    py = "m"
                } else if (tmp >= 50371 && tmp <= 50613) {
                    py = "n"
                } else if (tmp >= 50614 && tmp <= 50621) {
                    py = "o"
                } else if (tmp >= 50622 && tmp <= 50905) {
                    py = "p"
                } else if (tmp >= 50906 && tmp <= 51386) {
                    py = "q"
                } else if (tmp >= 51387 && tmp <= 51445) {
                    py = "r"
                } else if (tmp >= 51446 && tmp <= 52217) {
                    py = "s"
                } else if (tmp >= 52218 && tmp <= 52697) {
                    py = "t"
                } else if (tmp >= 52698 && tmp <= 52979) {
                    py = "w"
                } else if (tmp >= 52980 && tmp <= 53688) {
                    py = "x"
                } else if (tmp >= 53689 && tmp <= 54480) {
                    py = "y"
                } else if (tmp >= 54481 && tmp <= 62289) {
                    py = "z"
                } else {
                    py = s.charAt(0);
                }
                return py;
            }
        }

    </script>

    <style type="text/css">
        #TextArea1 { height: 225px; width: 840px; }
        #TextArea2 { height: 318px; width: 842px; }
        #txtData1 { height: 242px; width: 839px; }
        #txtData2 { height: 292px; width: 836px; }
    </style>
</head>
<body>
<div>注：涉及拼音转换的VBScript，仅支持IE哦</div>
    <p>
        校内网学校数据</p>
    <p>
        <textarea id="txtData1"></textarea></p>
    <p>
        <input id="btnConvert" type="button" value="转换" /></p>
    <p>
        转换后的数据</p>
    <p>
        <textarea id="txtData2"></textarea></p>
</body>
</html>
